package com.presto.directo.utils

fun String?.appendAmountUnit(): String {
    if (isNullOrEmpty()) {
        return "N/A"
    }
    val amount = toLongOrNull() ?: return "$$this"
    return if (amount >= 0) "$$amount" else "$-$amount"
}

fun String?.appendDayUnit(): String {
    if (isNullOrEmpty()) {
        return "N/A"
    }
    return "$this Días"
}


fun Map<String, String?>.toUrl(): String {
    var url = ""
    forEach {
        if (it.key.isNotEmpty() && !it.value.isNullOrBlank()) {
            url += "&" + it.key + "=" + it.value
        }
    }
    return url.replaceFirst("&", "?")
}